﻿@using Church.Common
@model DataBaseLayer.Dto.NewsData
@{
	ViewBag.Title = Model != null ? Model.Header : "Новости";
}

@if (Model != null)
{
	<div>
		<span>
			<h2>@(Model.Header ?? string.Empty)</h2>
		</span>
	</div>
	<div id="backspace" class="back">
		<a href="@(Url.Action<NewsController>(m => m.Index(Model.PageNumber)))">Назад</a>
	</div>
	<div class="news">
		@if (Model.IsNewsForGalleryImages)
		{
			<a href="@(Url.Action<GalleriesController>(m => m.Slider(Model.GalleryId)))">
				<img src="../../@(!string.IsNullOrWhiteSpace(Model.ImageUrl) ? Model.ImageUrl : Constants.DEFAULT_PUZZLE_IMAGE_URL)" />
			</a>
		}
		else if (Model.IsNewsForFotoClubImages)
		{
			<a href="@(Url.Action<FotoClubController>(m => m.Slider(Model.GalleryId)))">
				<img src="../../@(!string.IsNullOrWhiteSpace(Model.ImageUrl) ? Model.ImageUrl : Constants.DEFAULT_PUZZLE_IMAGE_URL)" />
			</a>
		}
		else
		{
			<a href="@Constants.EMPTY_ANCHOR_LINK">
				<img src="../../@(!string.IsNullOrWhiteSpace(Model.ImageUrl) ? Model.ImageUrl : Constants.DEFAULT_PUZZLE_IMAGE_URL)" />
			</a>
		}
		@if (Model.Description != null)
		{
			foreach (var paragraph in Model.Description.Split(new[] { Constants.NEW_LINE_SEPARATOR }, StringSplitOptions.RemoveEmptyEntries))
			{
				<p>@(paragraph ?? string.Empty)</p>
			}
		}
	</div>
}